﻿using Microsoft.AspNetCore.Mvc;
using Abp.AspNetCore.Mvc.Authorization;
using Neocean.Mpa.Controllers;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Options;
using System.Threading.Tasks;

namespace Neocean.Mpa.Web.Controllers
{
    [AbpMvcAuthorize]
    public class AboutController : MpaControllerBase
    {
        // ===================================
        private readonly ILogger<AboutController> _logger;
        /// <summary>
        /// The schemes
        /// </summary>
        protected readonly IAuthenticationSchemeProvider Schemes;

        /// <summary>
        /// The handlers
        /// </summary>
        protected readonly IAuthenticationHandlerProvider Handlers;
        private readonly IOptions<AuthenticationOptions> _authOptions;

        public AboutController(
            IAuthenticationSchemeProvider schemes,
            IAuthenticationHandlerProvider handlers,
            IOptions<AuthenticationOptions> options,
            ILogger<AboutController> logger)
        {

            _logger = logger;

            _authOptions = options;
            Schemes = schemes;
            Handlers = handlers;
        }

        // ===================================
        //public ActionResult Index()
        //{
        //    return View();
        //}
        public async Task<IActionResult> Index()
        {

            // ===================================
            var opt = _authOptions;
            var defaultScheme = await Schemes.GetDefaultAuthenticateSchemeAsync();
            var s2 = await Schemes.GetDefaultChallengeSchemeAsync();
            var s3 = await Schemes.GetDefaultSignInSchemeAsync();
            var handler = await Handlers.GetHandlerAsync(HttpContext, defaultScheme.Name);
            var result2 = await handler.AuthenticateAsync();
            // ===================================

            return View();
        }
    }
}
